package com.dts.listener;

import jakarta.servlet.ServletContextAttributeEvent;
import jakarta.servlet.ServletContextAttributeListener;
import jakarta.servlet.annotation.WebListener;

import java.text.MessageFormat;

@WebListener
public class MyContextAttributeLitener
        implements ServletContextAttributeListener {
    @Override
    public void attributeAdded(ServletContextAttributeEvent event)  {
        System.out.println(MessageFormat.format("ServletRequest add Attribute  name : {0}，value : {1}",  event.getName(), event.getValue()));
    }
    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println(MessageFormat.format("ServletRequest replace Attribute name : {0}，value : {1}", event.getName(),event.getValue()));
    }
    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println(MessageFormat.format("ServletRequest remove Attribute name : {0}，value : {1}", event.getName(), event.getValue()));
    }
}

